<script>
//array of participating td's ids
var navid_array = new Array();
navid_array[0] = 'nav1';
navid_array[1] = 'nav2';
navid_array[2] = 'nav3';

var state1 = '#FFFFFF'; //initial colour
var state2 = '#FE3000'; //onclick colour

function nav_colour_swap(navid) {
	
for(var i = 0; i < navid_array.length; i++) {
	
var nav = document.getElementById(navid_array[i]);
if(navid == nav.id) { //selected td
nav.style.backgroundColor = state2;
}
else { //other td
nav.style.backgroundColor = state1;
}
}
}
</script>

<table border="2" cellspacing="0" cellpadding="0" >
<tr  bgcolor="#6699CC">

<td class="tablecells" id="nav1" onclick="nav_colour_swap(this.id)">1</td>


<td class="tablecells" id="nav2" onclick="nav_colour_swap(this.id)"><a href="#" id="nav2">2</a></td>


<td class="tablecells" id="nav3" onclick="nav_colour_swap(this.id)"><a href="#" id="nav3">3</a></td>

</tr>
</table>